<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let cart = [
        { name: "iphone", price: 12000 },
        { name: "imac", price: 22000 },
        { name: "ipad", price: 8000 },
      ];

      function getNameByPrice(goods, price) {
        return goods.reduce((a, b) => {
          if (b.price > price) {
            a.push(b);
          }
          return a;
        }, []);
      }
      console.log(getNameByPrice(cart, 10000));

      // 数组去重
      let arr = [1, 22, 22, 3, 3, 4, 5, 6, 6];
      let disc = arr.reduce((a, b) => {
        if (!a.includes(b)) {
          a.push(b);
        }
        return a;
      }, []);
      console.log(disc);
    </script>
  </body>
</html>
